﻿/// <reference path="ADS.js" />
/*Menu*/
ADS.addEvent(window, 'load',initMenu);

function initMenu() { 
    //控制菜单项
    var titles = ADS.getElementByClassName('left_title', 'div');
    for (var i = 0; i < titles.length; i++) {
        ADS.addEvent(titles[i], 'click', showMenu);
    }
    var items = ADS.getElementByClassName('menu_item', 'a');
    for (var i = 0; i < items.length; i++) {
        ADS.addEvent(items[i], 'click', function (W3CEvent) {
            if (this.title == '') {
                alert('Not Finished Yet!!');
                ADS.preventDefault(W3CEvent);
            }
        });
    }
    //控制菜单页
        ADS.addEvent(ADS.$('switchBtn'), 'click', function () {
            if (this.title == 'Close') {
                parent.document.getElementById('mainFrame').cols = '0,*';
                this.title = 'Open';
                this.src = 'images/butOpen.gif';
            }
            else {
                parent.document.getElementById('mainFrame').cols = '206,*';
                this.title = 'Close';
                this.src = 'images/butClose.gif';
            }
        });
    //控制头部
    ADS.addEvent(ADS.$('switchTop'), 'click', function () {
        if (this.title == 'Hide Top') {
            this.title = 'Show Top';
            this.src = '/images/show_top.png';
            parent.document.getElementById("topFrame").rows = '0,*';
        }
        else {
            this.title = 'Hide Top';
            this.src = '/images/hide_top.png';
            parent.document.getElementById("topFrame").rows = '105,*';
        }

    });
}
function showMenu() {
    var titles = ADS.getElementByClassName('left_title', 'div');
    for (var i = 0; i < titles.length; i++) {
        
        var node = ADS.nextElement(titles[i], 'div');
        if (node!=null) {
            node.style.display = 'none';
        }
        imgPath(titles[i],'/images/arrow.gif')

    }
    var current=ADS.nextElement(this, 'div');
    if ( current!= null) {
        current.style.display = 'block';
        imgPath(this,'/images/arrow_down.gif');      
    }
}

//设置子结点中第一个IMG结点的路径
function imgPath(node,path) { 
    var childs=node.childNodes;
    for (var i = 0; i < childs.length; i++) {
        if (childs[i].nodeName == 'IMG') {
            childs[i].src = path;
        }
    }
}
/*--MenuTop--*/
ADS.addEvent(window, 'load', btnClick);
function btnClick() {
    ADS.addEvent(ADS.$('refresh_btn'), 'click', function () {
        var frame = window.parent.contentFrame;
        frame.location.reload();
    });
}

/*-----------------------------------------------------------------------------*/



